<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>爬楼梯</title>
</head>

<body>
  <script>
    function arr(n) {
      let num1 = 0, num2 = 0, res = 1;
      for (let i = 1; i <= n; i++) {
        num1 = num2;
        num2 = res;
        res = num1 + num2;
      }
      return res;
    };
    console.log(arr(2));
  </script>
</body>

</html>